﻿@using System;
@using Destiny.Core.Flow.CodeGenerator;

@{

    ProjectMetadata metadata = Model;
}
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using @(metadata.Namespace).Entities;
namespace @(metadata.Namespace).EntityConfigurations
{

    /// &lt;summary&gt;
    /// @(string.IsNullOrEmpty(metadata.EntityMetadata.DisplayName) ? metadata.EntityMetadata.EntityName : metadata.EntityMetadata.DisplayName)
    /// &lt;/summary&gt;
    public partial class @(metadata.EntityMetadata.EntityName)Configuration : EntityMappingConfiguration&lt;@(metadata.EntityMetadata.EntityName), @(metadata.EntityMetadata.PrimaryKeyType)&gt;
    {
        /// &lt;summary&gt;
        /// 重写以实现实体类型各个属性的数据库配置
        /// &lt;/summary&gt;
        /// &lt;param name="builder"&gt;实体类型创建器&lt;/param&gt;
        public override void Map(EntityTypeBuilder&lt;@metadata.EntityMetadata.EntityName&gt; builder)
        {
            builder.HasKey(x => x.Id);
        @foreach (var property in metadata.EntityMetadata.Properties)
        {
            <text>
            builder.Property(x => x.@(property.PropertyName)).HasComment("@property.DisplayName").IsRequired(@(property.IsNullable.ToString().ToLower()));</text>
        }

            builder.ToTable("@metadata.EntityMetadata.EntityName");
        }
    }
}